﻿using Ewk.MachineLearning.Genetic.Programming.Program.Terminals;

namespace Ewk.MachineLearning.Genetic.Programming.Program
{
    /// <summary>
    /// The terminal node repersents a variable or constant of the program.
    /// </summary>
    internal abstract class TerminalNode : Node
    {
        protected TerminalNode(Terminal terminal)
        {
            Terminal = terminal;
        }

        #region Overrides of Node

        public override dynamic GetValue()
        {
            return Terminal.Value;
        }

        #endregion

        /// <summary>
        /// The inner value of this node.
        /// </summary>
        protected Terminal Terminal { get; private set; }

        public ITerminalDefinition TerminalDefinition
        {
            get { return Terminal; }
        }

        public override string ToString()
        {
            return Terminal.Value.ToString();
        }
    }
}